Skip to content

Split processkit::ErrorKind from processkit::Error#22

Open
Techcable wants to merge 1 commit into
ZelAnton:mainfrom
Techcable:refactor/error-split-errorkind
Open

Split processkit::ErrorKind from processkit::Error#22
Techcable wants to merge 1 commit into
ZelAnton:mainfrom
Techcable:refactor/error-split-errorkind

Conversation

@Techcable

Copy link
Copy Markdown

What & why

The processkit::Error enum takes over 100 bytes, bloating every Result and triggering clippy lints. See issue #21 for details.

This is the suggested fix, moving all enum variants to a new processkit::ErrorKind struct and making processkit::Error an opaque struct wrapping Box<ErrorKind>.

Checklist

  • cargo fmt --all
  • cargo clippy --all-targets --all-features -- -D warnings is clean
  • cargo test passes (and cargo test --all-features -- --ignored if you
    touched spawn / containment / streaming paths)
  • CHANGELOG.md [Unreleased] updated when the change is user-facing
    (Added / Changed / Fixed)
  • Docs updated (rustdoc and the docs/ guide set) if behavior or API changed
  • (N/A) New dependencies carry a "why" comment in Cargo.toml (see CONTRIBUTING.md)

Notes for reviewers

There is some code that could be cleaner if we used if let guards in match.
This would require bumping the MSRV to Rust 1.95.

Right now in src/runner.rs around line 810 we do

let mut child = match group.spawn_with_options(&mut tokio_cmd, &opts) {
    Ok(child) => child,
    Err(e)
        if matches!(e.kind(), crate::ErrorKind::Spawn { source, .. } if source.kind() == std::io::ErrorKind::NotFound) =>
    {
         // some code
    },
    Err(other) => return Err(other)
};

If we bump the MSRV to 1.95, this could change into the following code:

let mut child = match group.spawn_with_options(&mut tokio_cmd, &opts) {
    Ok(child) => child,
    Err(e)
        if let crate::ErrorKind::Spawn { source, .. } = e.kind()
            && source.kind() == std::io::ErrorKind::NotFound => {
        // some code
    },
    Err(other) => return Err(other)
};

The Error enum was over 100 bytes, bloating every Result
and triggering clippy lints result_large_err and large_enum_variant.

It's now an opaque struct wrapping Box<ErrorKind>, taking up only 8 bytes.
Matching is now performed using the `err.kind()` instead of directly on `err`.
The is_* classifiers are now available on both Error and ErrorKind.

Fixes ZelAnton#21

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@Techcable
Techcable force-pushed the refactor/error-split-errorkind branch from ee7150b to 70f0db3 Compare July 23, 2026 02:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant